Skip to content

zlib: avoid mutable push in sync output collection - #67748

Open
rozzilla wants to merge 2 commits into
nodejs:mainfrom
rozzilla:zlib-sync-output-no-push
Open

rozzilla wants to merge 2 commits into
nodejs:mainfrom
rozzilla:zlib-sync-output-no-push

Conversation

@rozzilla

@rozzilla rozzilla commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This follows the suggestion in #67456 (comment) to protect code that intentionally doesn't use primordials (node:zlib is listed in doc/contributing/primordials.md) by replacing user-mutable .push() with indexed assignments.
The new test covers both paths.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies. labels Nov 24, 2026
processChunkSync() and processSyncWithDefaults() collected output
chunks with buffers.push(), which looks up Array.prototype.push at call
time. Replacing that method from user code changed how synchronous zlib
calls such as gunzipSync() collected their output. Use indexed
assignments instead.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@rozzilla
rozzilla force-pushed the zlib-sync-output-no-push branch from ca096e5 to f12c2b2 Compare November 24, 2026 13:15
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.51%. Comparing base (e7db489) to head (23ed32b).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67748      +/-   ##
==========================================
- Coverage   90.55%   90.51%   -0.05%     
==========================================
  Files         803      805       +2     
  Lines      285111   285756     +645     
  Branches    55039    55162     +123     
==========================================
+ Hits       258186   258644     +458     
- Misses      17080    17199     +119     
- Partials     9845     9913      +68     
Files with missing lines Coverage Δ
lib/zlib.js 98.41% <100.00%> (ø)

... and 49 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants